package com.bite.demo.controller;

import com.bite.demo.service.LogInfoService;
import com.bite.demo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.flyway.FlywayDataSource;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/propaga")
public class PropagationController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private LogInfoService logInfoService;

    @RequestMapping("/r1")
    @Transactional(propagation = Propagation.REQUIRED)
    public String r1(String name, String password){
        //用户注册
        userInfoService.registryUser(name, password);
        //记录操作日志
        logInfoService.insertLog(name, "用户注册");
        return "r1";
    }
}
